package com.zsrt.java.day20161226.cg.demo04;

import org.junit.Test;

public class s {

	/**
	 * 输入一个不大于5位的正整数，然后判断它是几位数，打印出各位数，并逆序输出这个整数。 1<=x<=99999 10000
	 * 
	 *
	 */
	public class Demo02 {

		
		public void main(String[] args) {

			// 1 让用户从键盘输入1个数字

			int num = 23456;

			if (num / 10000 >= 1) {

				int[] arrays = new int[5];
				int gewei = qiugewei(num);
				arrays[0] = gewei;
				int shiwei = num % 100 / 10;
				arrays[1] = shiwei;
				int baiwei = num % 1000 / 100;
				arrays[2] = baiwei;
				int qianwei = num % 10000 / 1000;
				arrays[3] = qianwei;
				int wanwei = num / 10000;
				arrays[4] = wanwei;

				printArray(arrays);

				System.out.println("5位数...");
			} else if (num / 1000 >= 1) {
				qiugewei(num);
				int shiwei = num % 100 / 10;
				int baiwei = num % 1000 / 100;
				int qianwei = num / 1000;
				System.out.println("4位数...");

			} else if (num / 100 >= 1) {
				System.out.println("3位数...");
			} else if (num / 10 >= 1) {
				System.out.println("2位数...");

			} else {
				System.out.println("1位数...");

			}
			// 2 /求整数来做 知道它是几位数
			// System.out.println(34/100);

		}

		public int qiugewei(int num) {
			int gewei = num % 10;
			return gewei;
		}
		public int qiushiwei(int num) {
			int gewei = num / 100 % 10;
			return gewei;
		}
		public int qiubaiwei(int num) {
			int gewei = num % 1000 / 100;
			return gewei;
		}
		public int qiuqianwei(int num) {
			int gewei = num % 10000 / 1000;
			return gewei;
		}
		public int qiuwanwei(int num) {
			int gewei = num / 10000;
			return gewei;
		}

		public void printArray(int[] arrays) {
			int len = arrays.length;
			// System.out.println("len="+len);
			for (int index = 0; index <= len - 1; index++) {
				int value = arrays[index];
				if (index == len - 1) {
					System.out.print(value);
					break;
				}
				System.out.print(value + ", ");
			}
			System.out.println();
		}

	}

}
